<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <if condition="($pt_type eq 0)">
            <li><a href="{:U('Padtrial/index')}">电审未审核列表</a></li>
            <else/>
            <li><a href="{:U('Padtrial/renew_padtrial')}">续借电审列表</a></li>
        </if>
        <li class="active"><a>电审记录</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" method="post">
        <fieldset>
            <div class="tabbable">
                <div class="tab-content">

                    <fieldset>
                        <div class="control-group">
                            <label class="control-label">姓名</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.name}&nbsp&nbsp&nbsp&nbsp{$order['account_status']?'[已认证]':'[未认证]'}</label>
                                <input type="hidden" name="options[id]" value="{$order.id}">
                                <input type="hidden" name="options[user_id]" value="{$order.user_id}">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">手机号码</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.mobile}</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">借款金额</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.amount}元</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">借款天数</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.loan_day}天</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">放款日</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.loan_time}</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">分期数</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.stages}期</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">咨询费</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">{$order.interest}元</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">审核费</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$order.examine}元</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">顾问费</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$order.consulting}元</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">到期应还</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$order.loan_amount}元</label></div>
                        </div>
                        <br />
                        <div class="control-group">
                            <label class="control-label">分期详情</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">
                                    <!--<table border="1" style='text-align:center;width:800px' cellpadding='10px'>-->
                                    <table class="table table-bordered">
                                        <tr>
                                            <th>期数</th>
                                            <th>到期时间</th>
                                            <th>借款状态</th>
                                            <th>分期金额</th>
                                            <th>审核操作</th>
                                        </tr>
                                        <php>$haikuanjine=0;
                                            $qishu=0;
                                            $daoqi=array();
                                        </php>
                                        <php>$rei=0;$stu_type=array('1'=>'借款中','2'=>'已还款','3'=>'逾期','4'=>'已到期','5'=>'审核中','6'=>'审核不通过','7'=>'驳回','8'=>'放款成功','9'=>'放款不成功','10'=>'待放款')</php>
                                        <foreach name="sub" item="vo">
                                            <tr>
                                                <php>$stag=substr($vo['stages'], 1);$stages=substr($vo['stages'],0, 1);</php>
                                                <td>第{$stages}期
                                                    <if condition="$stag">第{$stag}次续期
                                                    </if>
                                                <td>{$vo.endtime}</td>
                                                <td>{$stu_type[$vo['status']]}</td>
                                                <td>{$vo.amount}</td>
                                                <td>
                                                    <php>
                                                        if($vo['status']==3){
                                                        $haikuanjine+=$vo['amount'];
                                                        }
                                                        if($vo['status']==3){
                                                        $daoqi[]=substr($vo['stages'],0,1);
                                                        if(empty($qishu)){
                                                        $qishu=$vo['stages'];
                                                        }
                                                        }
                                                    </php>
                                                </td>
                                            </tr>
                                        </foreach>
                                        <tr>
                                            <td>共{$order.stages}期</td>
                                            <td>{$order.loan_day}天</td>
                                            <td>{$stu_type[$order['status']]}</td>
                                            <td>{$order.amount}</td>
                                            <td></td>
                                        </tr>
                                    </table>
                                </label>
                            </div>
                            <input type="hidden" name="options[stages]" value="{$qishu}">
                        </div>
                        <div class="control-group">
                            <label class="control-label">续期详情</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">
                                    <if condition="(empty($renewal))">
                                        暂无记录
                                        <else/>
                                        <!--<table border="1" style='text-align:center;width:800px' cellpadding='10px'>-->
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>借款编号</th>
                                                <th>续期时间</th>
                                                <th>完结时间</th>
                                                <th>续期金额</th>
                                                <th>审核备注</th>
                                                <th>状态</th>
                                                <th>审核人</th>
                                            </tr>
                                            <foreach name="renewal" item="vo">
                                                <tr>
                                                    <td>{$vo.order_id}</td>
                                                    <td>{$vo.renewal}</td>
                                                    <td>{$vo.endtime}</td>
                                                    <td>{$vo.amount}</td>
                                                    <td>{$vo.message}</td>
                                                    <td>{$vo['status']==1?'审核成功':'审核失败'}</td>
                                                    <td>{$lastuser[$vo['lastuser_id']]|default='系统'}</td>
                                                </tr>
                                            </foreach>
                                        </table>
                                    </if>
                                </label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">审核记录</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">
                                    <if condition="(empty($logs))">
                                        暂无记录
                                        <else/>
                                        <!--<table border="1" style='text-align:center;width:800px' cellpadding='10px'>-->
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>审核类型</th>
                                                <th>审核时间</th>
                                                <th>审核备注</th>
                                                <th>金额</th>
                                                <th>实收金额<br/>(不含逾期费)</th>
                                                <th>实收逾期费</th>
                                                <th>微信实收</th>
                                                <th>支付宝实收</th>
                                                <th>银行实收</th>
                                                <th>审核操作</th>
                                                <th>审核人</th>
                                                <th>收款人</th>
                                            </tr>
                                            <php>$stu_type=array('1'=>'借款中','2'=>'已还款','3'=>'逾期','4'=>'已到期','5'=>'审核中','6'=>'审核不通过','7'=>'驳回','8'=>'放款成功','9'=>'放款不成功','10'=>'待放款');
                                                $stu_ty=array('0'=>'用户审核','1'=>'订单审核','2'=>'订单审核','3'=>'续期审核','4'=>'逾期还款(本金)','5'=>'逾期还款','6'=>'订单审核','7'=>'客户还款');
                                            </php>
                                            <foreach name="logs" item="vo">
                                                <tr>
                                                    <php>
                                                        if($order['stages']==1){
                                                        if($vo['types']==7 || $vo['types']==4){
                                                        if($vo['status']){
                                                        $haikuanjine-=$vo['amount'];
                                                        }
                                                        }
                                                        }else{
                                                        if(in_array(substr($vo['stages'],0,1),$daoqi)){
                                                        if($vo['types']==7 || $vo['types']==4){
                                                        if($vo['status']){
                                                        $haikuanjine-=$vo['amount'];
                                                        }
                                                        }
                                                        }
                                                        }
                                                    </php>
                                                    <td>{$stu_ty[$vo['types']]}</td>
                                                    <td>{$vo.crtime}</td>
                                                    <td>{$vo.message}</td>
                                                    <td>{$vo.amount}</td>
                                                    <td>{$vo.real_amount|default='0.00'}</td>
                                                    <td>{$vo.overdue_amount|default='0.00'}</td>
                                                    <td>{$vo.wechat_amount}</td>
                                                    <td>{$vo.alipay_amount}</td>
                                                    <td>{$vo.bank_amount}</td>
                                                    <td>{$vo['status']?'审核成功':'审核失败'}</td>
                                                    <td>{$lastuser[$vo['examine_id']]|default='系统'}</td>
                                                    <td>{$lastuser[$vo['payee']]}</td>
                                                </tr>
                                            </foreach>
                                        </table>
                                    </if>
                                </label>
                            </div>
                        </div>
                        <div class="control-group">
                        <label class="control-label">电审记录</label>
                        <div class="controls">
                            <label class="control-label" style="width:auto">
                                <if condition="(empty($cs_list))">
                                    暂无记录
                                    <else/>
                                    <!--<table border="1" style='text-align:center;width:800px' cellpadding='10px'>-->
                                    <table class="table table-bordered">
                                        <tr>
                                            <th>电审说明</th>
                                            <th>记录时间</th>
                                            <th>审核人</th>
                                        </tr>
                                        <foreach name="cs_list" item="vo">
                                            <tr>
                                                <td>{$vo.collection_note}</td>
                                                <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                                                <td>{$lastuser[$vo['createby']]|default='系统'}</td>
                                            </tr>
                                        </foreach>
                                    </table>
                                </if>
                            </label>
                        </div>
                    </div>
                        <div class="control-group">
                            <label class="control-label">逾期管理员操作记录</label>
                            <div class="controls">
                                <label class="control-label" style="width:auto">
                                    <if condition="(empty($cs_list))">
                                        暂无记录
                                        <else/>
                                        <!--<table border="1" style='text-align:center;width:800px' cellpadding='10px'>-->
                                        <table class="table table-bordered">
                                            <tr>
                                                <th>原操作人</th>
                                                <th>逾期说明</th>
                                                <th>记录时间</th>
                                                <th>审核人</th>
                                            </tr>
                                            <foreach name="overdue_record" item="vo">
                                                <tr>
													<td>{$lastuser[$vo['user_id']]|default=''}</td>
                                                    <td>{$vo.record_note}<if condition="0 EQ $vo['record_type']">:{$vo.record_note_value}</if></td>
                                                    <td>{$vo.create_time}</td>
                                                    <td>{$lastuser[$vo['createby']]|default='系统'}</td>
                                                </tr>
                                            </foreach>
                                        </table>
                                    </if>
                                </label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">还款时间</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$order.endtime}</label></div>
                        </div>
                        <php>$overdue=check_amount_user_overdue($order['user_id']);</php>
                        <div class="control-group">
                            <label class="control-label">逾期天数</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$overdue.over_day|default='0'}天</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">逾期金额</label>
                            <php>$over_amount=yu_amount($order['user_id']);</php>
                            <div class="controls"><label class="control-label" style="width:auto">{$over_amount|default='0'}元</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">还款总金额</label>
                            <php>$haikuanjine=$over_amount+$haikuanjine</php>
                            <div class="controls"><label class="control-label" style="width:auto">{$haikuanjine|default='0'}元</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">账号余额</label>
                            <div class="controls"><label class="control-label" style="width:auto">{$order.deposit|default=0}元</label></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">电审记录</label>
                            <div class="controls">
                                <textarea name="options[collection_note]" rows="4" cols="30"></textarea>
                            </div>
                        </div>
                    </fieldset>
                </div>
            </div>

            <div class="form-actions">
                <button class="btn btn-primary js-ajax-submit" type="submit" data-types='1' data-action="{:U('Examine/after_collection',array('display'=>1,'disp'=>I('get.disp',0)))}" data-msg='审核确认?' data-subcheck="true">添加电审记录</button>
                <a class="btn btn-primary js-ajax-submit"  href="{:U('Examine/loan_overdue')}">返回</a>
            </div>
        </fieldset>
    </form>

</div>
<script src="__PUBLIC__/js/common.js"></script>
</body>
<script type="text/javascript">
    var ajaxForm_list = $('form.js-ajax-form');
    if (ajaxForm_list.length) {
        Wind.use('ajaxForm', 'artDialog', function () {

            $('button.js-ajax-submit').bind('click', function (e) {

                e.preventDefault();
                var btn = $(this),
                    form = btn.parents('form.js-ajax-form');

                //批量操作 判断选项
                if (btn.data('subcheck')) {
                    btn.parent().find('span').remove();
                    var msg = btn.data('msg');
                    if (msg) {
                        art.dialog({
                            id: 'warning',
                            icon: 'warning',
                            content: btn.data('msg'),
                            cancelVal: "{:L('CLOSE')}",
                            cancel: function () {

                            },
                            button :[ {
                                name : "{:L('OK')}",
                                callback:function(){
                                    ajaxSubmit(btn.data('types'));
                                },
                                focus : true
                            } ]
                        });
                    } else {
                        btn.data('subcheck', false);
                        btn.click();
                    }
                    return false;
                }
            });

        });
    }
    function ajaxSubmit(type){
        var btn = $('button.js-ajax-submit'),
            form = btn.parents('form.js-ajax-form');
        form.ajaxSubmit({
            url: type ? btn.data('action') : form.attr('action'),
            //按钮上是否自定义提交地址(多按钮情况)
            dataType: 'json',
            beforeSubmit: function (arr, $form, options) {
                var tx=type ? '电审记录提交通过' : '电审记录提交不通过';
                //按钮文案、状态修改
                btn.text(tx + '中...').attr('disabled', true).addClass('disabled');
            },
            success: function (data, statusText, xhr, $form) {
                //按钮文案、状态修改
                btn.removeClass('disabled').parent().find('span').remove();

                if (data.state === 'success') {
                    $('<span class="tips_success">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('slow').delay(1000).fadeOut(function () {
                        if (data.referer) {
                            //返回带跳转地址
                            if (window.parent.art) {
                                //iframe弹出页
                                window.parent.location.href = data.referer;
                            } else {
                                window.location.href = data.referer;
                            }
                        } else {
                            if (window.parent.art) {
                                reloadPage(window.parent);
                            } else {
                                //刷新当前页
                                reloadPage(window);
                            }
                        }
                    });
                } else if (data.state === 'fail') {
                    $('<span class="tips_error">' + data.info + '</span>').appendTo(btn.parent()).fadeIn('fast');

                    btn.text('电审记录提交不通过').removeProp('disabled').removeClass('disabled');
                }
            }
        });
    }


</script>
<script>
    $(function(){
        $('.just_can_number').keyup(function(){
            var obj = this;
            obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
            obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
            obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
            obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
        });
    });
</script>
</html>